package com.itheima.dao;

import com.itheima.pojo.OrderSetting;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.time.LocalDate;
import java.util.List;
import java.util.Map;

@Mapper
public interface OrderSettingDao {

    @Select("select * from t_ordersetting " +
            "where orderDate >= #{begin} " +
            "and orderDate <= #{end}")
    List<OrderSetting> findByMonth(LocalDate begin, LocalDate end);

    void insertBatch(List<Map<String, String>> list);

    @Update("update t_ordersetting set number = #{number} where orderDate = #{orderDate}")
    void updateNumber(Integer number, String orderDate);

    @Insert("insert into t_ordersetting(orderDate,number,reservations) values (#{orderDate},#{number},#{reservations})")
    void insert(String orderDate, Integer number, Integer reservations);

    @Select("select * from t_ordersetting where orderDate = #{orderDate}")
    OrderSetting getByOrderDate(String orderDate);

    @Update("update t_ordersetting set reservations = reservations + 1 where orderDate = #{orderDate}")
    void updateReservations(String orderDate);
}
